trigger Opportunity on Opportunity (after insert, after update, before insert, before update)
{
	if (TriggerContext.DisableOpportunityTriggers || TriggerContext.DisableTriggers)
	{
		return;
	}
	
	Map<Id, Opportunity> opportunities = new Map<Id, Opportunity>();
	if (trigger.isUpdate && trigger.isBefore)
	{
		for (Opportunity opportunity : trigger.new)
		{
			Opportunity oldOpportunity = trigger.oldMap.get(opportunity.Id);
			if (opportunity.StageName == 'Closed Won' && oldOpportunity.StageName != 'Closed Won')
			{
				opportunities.put(opportunity.Id, opportunity);
			}
		}
	}
	else
	{
		if (trigger.isInsert && trigger.isAfter)
		{
			for (Opportunity opportunity : trigger.new)
			{
				if (opportunity.StageName == 'Closed Won')
				{
					opportunities.put(opportunity.Id, opportunity);
				}		
			}
		}
	}
	
	if (!opportunities.isEmpty())
	{
		trg_OpportunityMethods.InsertKentechJobOnOpportunity(opportunities);
	}
}